package com.wk.webview.activity

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.wk.webview.R
import com.wk.webview.utils.Constants
import kotlinx.android.synthetic.main.activity_webview.*

class WebViewActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_webview)
        initViews()
    }

    @SuppressLint("SetJavaScriptEnabled")
    private fun initViews() {
        tv_back.setOnClickListener { onBackPressed() }
        ll_bar.visibility = if (intent.getBooleanExtra(
                Constants.WEB_VIEW_SHOW_ACTIONBAR,
                false
            )
        ) View.VISIBLE else View.GONE
        wv_webview.settings.javaScriptEnabled = true
        tv_web_title.text = intent.getStringExtra(Constants.WEB_VIEW_TITLE)
        wv_webview.loadUrl(intent.getStringExtra(Constants.WEB_VIEW_URL) ?: "")

    }

}